<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../../util/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>编辑公司信息</title>
    <link rel="stylesheet" type="text/css" href="${ctx}/fastCss/jquery.fast.form.css" />
</head>
<body>
<div id="selectAdminPage">
	 <div class="adminTools">
	    <!-- 表格工具栏 -->
        <div class="tb_toolbar">
			<form action="#" method="post" id="searchForm" class="grayForm" style="line-height: 40px">
			    &nbsp;
			    <input type="text" class="easyui-combotree" id="companyUUID" name="companyUUID" 
                           data-options="
                                prompt:'请选择单位',
                                width:230,
                                height:35,
                                panelHeight:350,
                                url:getBasePath()+'company/getCompanyList4Tree.do',    
				        	    valueField:'id',
				        	    textField:'text',
				        	    onChange:function(newValue, oldValue){
				        	       seachData();
				        	    },
				        	    onSelect:function(node){
				        	       $('#companyName').val(node.text);
				        	       loadDepartment(node.id);
							    }
				        	    "/>
				<select id="deptName" name="deptName" style="height:35px;" onchange="seachData()">
                   <option value="">请选择</option>
                </select>
			    <input type="text" class="easyui-textbox" data-options="width:200,prompt:'用户名'" onblur="seachData()" name="userName" style="margin: 5px"/>
			    <a href="javascript:seachData()" class="easyui-linkbutton"  data-options="iconCls:'icon-search'">检索</a>
		    </form>
	   </div>
      </div>
      <div class="adminList" style="width:800px;height:300px;">
      </div>
</div>
        <script type="text/javascript">
        $(document).ready(function () {
        	loadTableList();
        });
        
        //检索数据
        function seachData(){
           var searChObj = new Object(); 
           var formId = "searchForm";
           var companyUUID = $('#companyUUID').combotree('getValue');
           var userName = $('#userName').val();
           var deptName = $('#deptName').val();
           searChObj.companyUUID = companyUUID;
           searChObj.userName = userName;
           searChObj.deptName = deptName;
       
           $("#selectAdminPage .adminList").datagrid({
        	     queryParams:searChObj
           })
        }
        
        //加载列表
        function loadTableList(){
      	    //向后台加载数据
	    	$("#selectAdminPage .adminList").datagrid({
		        url:getBasePath()+"adminUser/getAdminList.do",
		        //远程请求数据的方式
		        method:"post",
		        fit:false,
		        //真正的自动展开/收缩列的大小，以适应网格的宽度，防止水平滚动。
		        fitColumns:true,
		        //调整列的位置
		        resizeHandle:"right",
		        //定义设置行的高度,根据该行的内容。设置为false可以提高负载性能
		        autoRowHeight:"false",
		        striped:true,
		        nowrap:true,
		        idField:"id",
		        rownumbers:true,//是否显示行号
		        pagination:true,
		        toolbarId:"#selectAdminPage .tb_toolbar",
  		        loadMsg:"数据加载中，请稍后...",
  		        pageSize:7,//页长
  		        pageList:[7,20,25,30],
		        singleSelect:false,
		        columns:[[
 	  		          {field:'uuid',checkbox:true},
  		              {field:'realName',title:'真实姓名',width:'20%',formatter:function(value, row, index) {
 				        	return '<font color=green><b>'+value+'</b></font>';
 					  }},
 					  {field:'userName',title:'用户名',width:'20%',formatter:function(value, row, index) {
				        	return '<font color=#843900><b>'+value+'</b></font>';
					  }},
  		              {field:'deptName',title:'所在部门',width:'20%'},
  		              {field:'groupName',title:'所属角色',width:'20%'}
  	  		    ]]
		    });
        }
        
        //加载部门信息
        function loadDepartment(companyUUID){
        	$.post(getBasePath()+"department/getDeptListByCompanyUUID.do",{companyUUID:companyUUID},function(jsonList) {
					var listhtml = "<option value=''>请选择</option>";
					var curDeptName = $("select[name='deptName']").attr("curV");
					$.each(jsonList, function(i, dept) {
					    if(curDeptName==dept.departmentName){
					        listhtml = listhtml + "<option selected value='"+dept.uuid+"@"+dept.departmentName+"'>"+dept.departmentName+ "</option>";
					        loadPosition(dept.id)
					    }else{
					        listhtml = listhtml + "<option value='"+dept.uuid+"@"+dept.departmentName+"'>"+dept.departmentName+ "</option>";
					    }
					});
					$("select[name='deptName']").html(listhtml);
		    },"json");
        }
    </script>
</div>
</body>
</html>